import {Injectable} from '@angular/core';
import {Observable} from "rxjs";
import {environment} from "../../../../../environments/environment";
import {HttpUtilService} from "../../../../services/http/http-util.service";

@Injectable({
  providedIn: 'root'
})
export class TeamRoleService {

  private prefix = environment.serverName.system + "/team-role/"

  constructor(private http: HttpUtilService) {
  }

  /**
   * 添加角色
   * @param id
   * @param roleIds
   * @param handleError
   */
  addRoleIds(id: string, roleIds: string[], handleError = true): Observable<void> {
    const param = {pid: id, roleIds};
    return this.http.post<void>(this.prefix + "addRoleIds", param, handleError);

  }

  /**
   * 删除team与角色关系
   * @param roleId
   * @param teamId
   * @param handleError
   */
  delete(roleId: string, teamId: string, handleError = true): Observable<void> {
    const param = {roleId, teamId}
    return this.http.post<void>(this.prefix + "delete", param, handleError);
  }
}
